<template>
    <el-input v-model="inputValue" :placeholder="placeholder" @change="changeInputHandle" />
</template>

<script lang="ts" setup name="SGInput">
import type { PropType } from 'vue';
import type { IComponentInfoType } from '@/types/component';

const props = defineProps({
    info: {
        required: true,
        type: Object as PropType<IComponentInfoType>,
        default: () => {}
    }
});

const emit = defineEmits<{
    (e: 'change', info: IComponentInfoType): void;
}>();

const placeholder = computed(() => {
    return props.info.placeholder || `请输入${props.info.label}`;
});

const inputValue = defineModel();

const changeInputHandle = (val: any) => {
    emit('change', props.info);
};
</script>
